<!DOCTYPE html>























































<html class="hasSidebar hasPageActions hasBreadcrumb conceptual has-default-focus theme-light" lang="zh-cn" dir="ltr"
    data-css-variable-support="true" data-authenticated="false" data-auth-status-determined="false" data-target="docs"
    x-ms-format-detection="none">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta property="og:title" content="欢迎回到 C++ - 现代 C++" />
    <meta property="og:type" content="website" />
    <meta property="og:url"
        content="https://learn.microsoft.com/zh-cn/cpp/cpp/welcome-back-to-cpp-modern-cpp?view=msvc-170" />
    <meta property="og:description" content="介绍现代 C++ 中的编程惯例及其基本原理。" />

    <meta property="og:image" content="https://learn.microsoft.com/en-us/media/open-graph-image.png" />

    <meta property="og:image:alt" content="Microsoft Learn" />

    <meta name="twitter:card" content="summary_large_image" />

    <meta name="twitter:site" content="@MicrosoftLearn" />

    <meta name="color-scheme" content="light dark">


    <meta name="audience" content="developer" />
    <meta name="author" content="TylerMSFT" />
    <meta name="breadcrumb_path" content="../_breadcrumb/toc.json" />
    <meta name="default_moniker" content="msvc-170" />
    <meta name="depot_name" content="VS.vcppdocs" />
    <meta name="description" content="介绍现代 C++ 中的编程惯例及其基本原理。" />
    <meta name="document_id" content="b83658b4-2e2f-f617-174d-6741575beca3" />
    <meta name="document_version_independent_id" content="09fd3e8d-d0e2-bfe9-ebdf-24b7c2b5db9e" />
    <meta name="feedback_system" content="None" />
    <meta name="git_commit_id" content="527f7437f87b73f77cc52cdba02ae9fdfc604349" />
    <meta name="gitcommit"
        content="https://github.com/MicrosoftDocs/cpp-docs-pr/blob/527f7437f87b73f77cc52cdba02ae9fdfc604349/docs/cpp/welcome-back-to-cpp-modern-cpp.md" />
    <meta name="loc_file_id" content="Github-70020392.live.VS.vcppdocs.cpp/welcome-back-to-cpp-modern-cpp.md" />
    <meta name="loc_source_id" content="Github-70020392#live" />
    <meta name="loc_version" content="2023-06-15T09:23:31.0350468Z" />
    <meta name="locale" content="zh-cn" />
    <meta name="manager" content="markl" />
    <meta name="monikers" content="msvc-140" />
    <meta name="monikers" content="msvc-150" />
    <meta name="monikers" content="msvc-160" />
    <meta name="monikers" content="msvc-170" />
    <meta name="ms.assetid" content="1cb1b849-ed9c-4721-a972-fd8f3dab42e2" />
    <meta name="ms.author" content="twhitney" />
    <meta name="ms.contentlocale" content="zh-cn" />
    <meta name="ms.date" content="06/02/2022" />
    <meta name="ms.prod" content="visual-cpp" />
    <meta name="ms.technology" content="cpp-language" />
    <meta name="ms.tgt_pltfrm" content="Windows" />
    <meta name="ms.topic" content="conceptual" />
    <meta name="ms.translationtype" content="HT" />
    <meta name="ms.workload" content="cplusplus" />
    <meta name="original_content_git_url"
        content="https://github.com/MicrosoftDocs/cpp-docs-pr/blob/live/docs/cpp/welcome-back-to-cpp-modern-cpp.md" />
    <meta name="page_type" content="conceptual" />
    <meta name="ROBOTS" content="INDEX,FOLLOW" />
    <meta name="schema" content="Conceptual" />
    <meta name="search.mshattr.devlang" content="c++ cpp" />
    <meta name="site_name" content="Docs" />
    <meta name="toc_rel" content="toc.json" />
    <meta name="uhfHeaderId" content="MSDocsHeader-CPP" />
    <meta name="updated_at" content="2023-10-27 11:16 PM" />
    <meta name="word_count" content="2961" />


    <meta name="recommendation_types" content="Training" />
    <meta name="recommendation_types" content="Certification" />


    <meta name="persistent_id" content="4ad5afd7-610c-31b2-a6e4-e3c2073bab8f" />



    <meta name="cmProducts"
        content="https://microsoft-devrel.poolparty.biz/DevRelOfferingOntology/c6f99e62-1cf6-4b71-af9b-649b05f80cce"
        data-source="generated" />

    <meta name="cmProducts"
        content="https://authoring-docs-microsoft.poolparty.biz/devrel/540ac133-a371-4dbb-8f94-28d6cc77a70b"
        data-source="generated" />

    <meta name="cmProducts"
        content="https://microsoft-devrel.poolparty.biz/DevRelOfferingOntology/12ed19f9-ebdf-4c8a-8bcd-7a681836774d"
        data-source="generated" />




    <meta name="spProducts"
        content="https://microsoft-devrel.poolparty.biz/DevRelOfferingOntology/3f56b378-07a9-4fa1-afe8-9889fdc77628"
        data-source="generated" />

    <meta name="spProducts"
        content="https://authoring-docs-microsoft.poolparty.biz/devrel/60bfc045-f127-4841-9d00-ea35495a5800"
        data-source="generated" />

    <meta name="spProducts"
        content="https://microsoft-devrel.poolparty.biz/DevRelOfferingOntology/3a764584-4f97-452b-8f1d-36f19b12f6ae"
        data-source="generated" />



    <meta name="scope" content="C++" />
    <meta name="github_feedback_content_git_url"
        content="https://github.com/MicrosoftDocs/cpp-docs/blob/main/docs/cpp/welcome-back-to-cpp-modern-cpp.md" />
    <link href="https://learn.microsoft.com/zh-cn/cpp/cpp/welcome-back-to-cpp-modern-cpp?view=msvc-170" rel="canonical">
    <title>欢迎回到 C++ - 现代 C++ | Microsoft Learn</title>

    <link rel="stylesheet" href="/_themes/docs.theme/master/zh-cn/_themes/styles/8b41fcf1.site-ltr.css ">



    <script id="msdocs-script">
        var msDocs = {
            data: {
                timeOrigin: Date.now(),
                contentLocale: 'zh-cn',
                contentDir: 'ltr',
                userLocale: 'zh-cn',
                userDir: 'ltr',
                pageTemplate: 'Conceptual',
                brand: '',
                context: {
                },
                hasBinaryRating: true,
                hasGithubIssues: false,
                feedbackHelpLinkType: '',
                feedbackHelpLinkUrl: '',
                standardFeedback: false,
                showFeedbackReport: false,
                enableTutorialFeedback: false,
                contentWellNotification: '',
                feedbackSystem: 'None',
                feedbackGitHubRepo: '',
                feedbackProductUrl: '',
                extendBreadcrumb: false,
                isEditDisplayable: false,
                hideViewSource: false,
                hasPageActions: true,
                hasPrintButton: true,
                hasBookmark: true,
                hasShare: true,
                isPermissioned: false,
                isPrivateUnauthorized: false,
                hasRecommendations: true,
                contributors: [
                    { name: "TylerMSFT", url: "https://github.com/TylerMSFT" },
                    { name: "colin-home", url: "https://github.com/colin-home" },
                    { name: "acminor", url: "https://github.com/acminor" },
                    { name: "Taojunshen", url: "https://github.com/Taojunshen" },
                    { name: "compnerd", url: "https://github.com/compnerd" },
                    { name: "mikeblome", url: "https://github.com/mikeblome" },
                    { name: "Mikejo5000", url: "https://github.com/Mikejo5000" },
                    { name: "ghogen", url: "https://github.com/ghogen" },
                    { name: "robert-andrzejuk", url: "https://github.com/robert-andrzejuk" },
                    { name: "Saisang", url: "https://github.com/Saisang" }
                ],
            },
            functions: {}
        };
    </script>
    <script src="https://wcpstatic.microsoft.com/mscc/lib/v2/wcp-consent.js"></script>
    <script src="https://js.monitor.azure.com/scripts/c/ms.jsll-3.min.js"></script>

    <script src="/_themes/docs.theme/master/zh-cn/_themes/global/67a45209.deprecation.js"></script>
    <link rel="preconnect" href="//mscom.demdex.net" crossorigin>
    <link rel="dns-prefetch" href="//target.microsoft.com">
    <link rel="dns-prefetch" href="//microsoftmscompoc.tt.omtrdc.net">
    <link rel="preload" as="script" href="/static/third-party/adobe-target/at-js/2.9.0/at.js"
        integrity="sha384-1/viVM50hgc33O2gOgkWz3EjiD/Fy/ld1dKYXJRUyjNYVEjSUGcSN+iPiQF7e4cu" crossorigin="anonymous"
        id="adobe-target-script" type="application/javascript" />
    <script src="/_themes/docs.theme/master/zh-cn/_themes/scripts/bde83f55.index-docs.js"></script>
</head>

<body lang="zh-cn" dir="ltr">
    <div class="header-holder has-default-focus">
        <a href="#main"
            class="skip-to-main-link has-outline-color-text visually-hidden-until-focused position-fixed has-inner-focus focus-visible top-0 left-0 right-0 padding-xs has-text-centered has-body-background"
            tabindex="1">跳转至主内容</a>

        <div hidden id="cookie-consent-holder" data-test-id="cookie-consent-container"></div>

        <div id="unsupported-browser" style="
			background-color: white;
			color: black;
			padding: 16px;
			border-bottom: 1px solid grey;" hidden>
            <div style="max-width: 800px; margin: 0 auto;">
                <p style="font-size: 24px">此浏览器不再受支持。</p>
                <p style="font-size: 16px; margin-top: 16px;">请升级到 Microsoft Edge 以使用最新的功能、安全更新和技术支持。</p>
                <div style="margin-top: 12px;">
                    <a href="https://go.microsoft.com/fwlink/p/?LinkID=2092881 " style="
						background-color: #0078d4;
						border: 1px solid #0078d4;
						color: white;
						padding: 6px 12px;
						border-radius: 2px;
						display: inline-block;
						">
                        下载 Microsoft Edge </a>
                    <a href="https://learn.microsoft.com/en-us/lifecycle/faq/internet-explorer-microsoft-edge" style="
							background-color: white;
							padding: 6px 12px;
							border: 1px solid #505050;
							color: #171717;
							border-radius: 2px;
							display: inline-block;
							">
                        有关 Internet Explorer 和 Microsoft Edge 的详细信息 </a>
                </div>
            </div>
        </div>
        <!-- liquid-tag banners global -->

        <!-- site header -->
        <div id="ms--site-header" class="uhf-container has-padding display-none"></div>

        <div id="headerAreaHolder" data-bi-name="header">
            <header role="banner" itemscope="itemscope" itemtype="http://schema.org/Organization">
                <div class="nav-bar">
                    <div class="nav-bar-brand">
                        <a itemprop="url" href="https://www.microsoft.com" aria-label="Microsoft"
                            class="nav-bar-button">
                            <div class="nav-bar-logo has-background-image theme-display is-light" role="presentation"
                                aria-hidden="true" itemprop="logo" itemscope="itemscope"></div>
                            <div class="nav-bar-logo has-background-image theme-display is-dark is-high-contrast"
                                role="presentation" aria-hidden="true" itemprop="logo" itemscope="itemscope"></div>
                        </a>
                    </div>
                </div>
                <div class="nav-bar border-top is-hidden-mobile"></div>
            </header>
        </div>


        <div id="content-header" class="content-header uhf-container has-padding has-default-focus border-bottom-none"
            data-bi-name="content-header">
            <div class="content-header-controls margin-xxs margin-inline-sm-tablet">
                <button type="button" class="contents-button button button-sm margin-right-xxs"
                    data-bi-name="contents-expand" aria-haspopup="true" data-contents-button>
                    <span class="icon"><span class="docon docon-menu" aria-hidden="true"></span></span>
                    <span class="contents-expand-title">
                        目录 </span>
                </button>
                <button type="button" class="ap-collapse-behavior ap-expanded button button-sm"
                    data-bi-name="ap-collapse" aria-controls="action-panel">
                    <span class="icon"><span class="docon docon-exit-mode" aria-hidden="true"></span></span>
                    <span>退出焦点模式</span>
                </button>
            </div>
        </div>

        <div id="disclaimer-holder" class="has-overflow-hidden has-default-focus">
            <!-- liquid-tag banners sectional -->
        </div>
    </div>

    <div class="mainContainer  uhf-container has-default-focus" data-bi-name="body">

        <div class="columns has-large-gaps is-gapless-mobile ">

            <div id="left-container"
                class="left-container is-hidden-mobile column is-one-third-tablet is-one-quarter-desktop">
                <nav id="affixed-left-container"
                    class="margin-top-sm-tablet position-sticky display-flex flex-direction-column" role="navigation"
                    aria-label="主要"></nav>
            </div>

            <!-- .primary-holder -->
            <section class="primary-holder column is-two-thirds-tablet is-three-quarters-desktop">
                <!--div.columns -->
                <div class="columns is-gapless-mobile has-large-gaps ">


                    <div id="main-column" class="column  is-full is-8-desktop">

                        <main id="main" class="" role="main" data-bi-name="content" lang="zh-cn" dir="ltr">
                            <!-- article-header -->
                            <div id="article-header"
                                class="background-color-body margin-top-sm-tablet margin-bottom-xs display-none-print">
                                <div class="display-flex align-items-center ">
                                    <details id="article-header-breadcrumbs-overflow-popover" class="popover"
                                        data-for="article-header-breadcrumbs">
                                        <summary class="button button-clear button-primary button-sm inner-focus"
                                            aria-label="所有痕迹">
                                            <span class="icon">
                                                <span class="docon docon-more"></span>
                                            </span>
                                        </summary>
                                        <div id="article-header-breadcrumbs-overflow"
                                            class="popover-content padding-none">

                                        </div>
                                    </details>

                                    <bread-crumbs id="article-header-breadcrumbs"
                                        data-test-id="article-header-breadcrumbs"
                                        class="overflow-hidden flex-grow-1 margin-right-sm margin-right-md-tablet margin-right-lg-desktop margin-left-negative-xxs padding-left-xxs"></bread-crumbs>

                                    <div id="article-header-page-actions"
                                        class="opacity-none margin-left-auto display-flex flex-wrap-no-wrap align-items-stretch">
                                        <div class="language dropdown display-flex align-items-center">
                                            <button
                                                class="dropdown-trigger button button-clear button-sm button-primary"
                                                aria-controls="language-menu" aria-expanded="false" title="语言"
                                                data-bi-name="language">
                                                <span class="lang-title align-self-flex-start" dir="ltr">语言</span>
                                                <span class="icon" aria-hidden="true">
                                                    <span
                                                        class="docon docon-chevron-down-light expanded-indicator"></span>
                                                </span>
                                            </button>
                                            <div class="dropdown-menu padding-xxs language-selector"
                                                name="language-selector" role="menu">
                                                <ul data-bi-name="language-links" dir="ltr">
                                                    <li>
                                                        <a class="button button-clear button-sm button-block"
                                                            data-bi-name="lang-c++" tabindex="0"
                                                            aria-selected="false"></a>
                                                    </li>
                                                    <li>
                                                        <a class="button button-clear button-sm button-block"
                                                            data-bi-name="lang-cpp" tabindex="0"
                                                            aria-selected="false"></a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>

                                        <a id="lang-link-tablet"
                                            class="button button-primary button-clear button-sm display-none display-inline-flex-tablet"
                                            title="使用英语阅读" data-bi-name="language-toggle" data-read-in-link hidden>
                                            <span class="icon margin-none" aria-hidden="true" data-read-in-link-icon>
                                                <span class="docon docon-locale-globe"></span>
                                            </span>
                                            <span class="is-visually-hidden" data-read-in-link-text>使用英语阅读</span>
                                        </a>

                                        <button type="button"
                                            class="collection button button-clear button-sm button-primary display-none display-inline-flex-tablet"
                                            data-list-type="collection" data-bi-name="collection" title="添加到集合">
                                            <span class="icon margin-none" aria-hidden="true">
                                                <span class="docon docon-circle-addition"></span>
                                            </span>
                                            <span class="collection-status is-visually-hidden">保存</span>
                                        </button>






                                        <details class="popover popover-right"
                                            id="article-header-page-actions-overflow">
                                            <summary
                                                class="justify-content-flex-start button button-clear button-sm button-primary"
                                                aria-label="更多操作">
                                                <span class="icon" aria-hidden="true">
                                                    <span class="docon docon-more-vertical"></span>
                                                </span>
                                            </summary>
                                            <div class="popover-content padding-none">
                                                <button data-page-action-item="overflow-mobile" type="button"
                                                    class="justify-content-flex-start button-block button-sm has-inner-focus button button-clear display-none-tablet"
                                                    data-bi-name="contents-expand" data-contents-button
                                                    data-popover-close>
                                                    <span class="icon">
                                                        <span class="docon docon-editor-list-bullet"
                                                            aria-hidden="true"></span>
                                                    </span>
                                                    <span class="contents-expand-title">目录</span>
                                                </button>

                                                <a id="lang-link-overflow"
                                                    class="justify-content-flex-start button-sm has-inner-focus button button-clear button-block display-none-tablet"
                                                    title="使用英语阅读" data-bi-name="language-toggle"
                                                    data-page-action-item="overflow-mobile" data-check-hidden="true"
                                                    data-read-in-link hidden>
                                                    <span class="icon" aria-hidden="true" data-read-in-link-icon>
                                                        <span class="docon docon-locale-globe"></span>
                                                    </span>
                                                    <span data-read-in-link-text>使用英语阅读</span>
                                                </a>

                                                <button type="button"
                                                    class="collection justify-content-flex-start button button-clear button-sm has-inner-focus button-block display-none-tablet"
                                                    data-list-type="collection" data-bi-name="collection" title="添加到集合"
                                                    data-page-action-item="overflow-mobile" data-check-hidden="true"
                                                    data-popover-close>
                                                    <span class="icon" aria-hidden="true">
                                                        <span class="docon docon-circle-addition"></span>
                                                    </span>
                                                    <span class="collection-status">保存</span>
                                                </button>


                                                <button
                                                    class="button button-block button-clear button-sm justify-content-flex-start has-inner-focus"
                                                    title="打印" type="button" aria-label="打印" data-bi-name="print"
                                                    data-page-action-item="overflow-all" data-popover-close
                                                    data-print-page data-check-hidden="true">
                                                    <span class="icon" aria-hidden="true">
                                                        <span class="docon docon-print"></span>
                                                    </span>
                                                    <span>打印</span>
                                                </button>

                                                <div aria-hidden="true" class="margin-none
														border-top" data-page-action-item="overflow-all"></div>


                                                <a class="button button-clear button-sm has-inner-focus button-block text-decoration-none justify-content-flex-start share-twitter"
                                                    data-bi-name="twitter" data-page-action-item="overflow-all">
                                                    <span class="icon" aria-hidden="true">
                                                        <span class="docon docon-brand-twitter"></span>
                                                    </span>
                                                    <span>Twitter</span>
                                                </a>
                                                <a class="button button-clear button-sm has-inner-focus button-block text-decoration-none justify-content-flex-start share-linkedin"
                                                    data-bi-name="linkedin" data-page-action-item="overflow-all">
                                                    <span class="icon" aria-hidden="true">
                                                        <span class="docon docon-brand-linkedin"></span>
                                                    </span>
                                                    <span>LinkedIn</span>
                                                </a>
                                                <a class="button button-clear button-sm button-block has-inner-focus text-decoration-none justify-content-flex-start share-facebook"
                                                    data-bi-name="facebook" data-page-action-item="overflow-all">
                                                    <span class="icon" aria-hidden="true">
                                                        <span class="docon docon-brand-facebook"></span>
                                                    </span>
                                                    <span>Facebook</span>
                                                </a>
                                                <a class="button button-clear button-sm button-block has-inner-focus text-decoration-none justify-content-flex-start share-email"
                                                    data-bi-name="email" data-page-action-item="overflow-all">
                                                    <span class="icon" aria-hidden="true">
                                                        <span class="docon docon-mail-message-fill"></span>
                                                    </span>
                                                    <span>电子邮件</span>
                                                </a>

                                            </div>
                                        </details>

                                    </div>
                                </div>
                            </div>
                            <!-- end article-header -->


                            <div>
                                <button type="button"
                                    class="border contents-button button button-clear button-sm is-hidden-tablet has-inner-focus"
                                    data-bi-name="contents-expand" data-contents-button hidden>
                                    <span class="icon">
                                        <span class="docon docon-editor-list-bullet" aria-hidden="true"></span>
                                    </span>
                                    <span class="contents-expand-title">目录</span>
                                </button>
                            </div>

                            <!-- end mobile-contents button  -->

                            <div class="content ">


                                <h1 id="welcome-back-to-c---modern-c">欢迎回到 C++ - 现代 C++</h1>


                                <div
                                    class="display-flex justify-content-space-between align-items-center flex-wrap-wrap page-metadata-container">
                                    <div class="margin-right-xxs">
                                        <ul class="metadata page-metadata" data-bi-name="page info" lang="zh-cn"
                                            dir="ltr">
                                            <li>
                                                项目 </li>

                                            <li class="visibility-hidden-visual-diff">
                                                <time class="is-invisible" data-article-date aria-label="文章评审日期"
                                                    datetime="2023-04-03T00:00:00Z"
                                                    data-article-date-source="calculated">04/03/2023</time>
                                            </li>
                                            <li class="contributors-holder display-none-print">
                                                <button aria-label="查看所有参与者" class="contributors-button link-button"
                                                    data-bi-name="contributors" title="查看所有参与者">
                                                    10 个参与者
                                                </button>
                                            </li>
                                        </ul>
                                    </div>

                                    <div id="user-feedback" class="margin-block-xxs display-none-print"
                                        data-hide-on-archived>
                                        <button id="user-feedback-button" data-test-id="conceptual-feedback-button"
                                            class="button button-sm button-clear button-primary" type="button"
                                            data-bi-name="user-feedback-button" data-user-feedback-button>
                                            <span class="icon" aria-hidden="true">
                                                <span class="docon docon-like"></span>
                                            </span>
                                            <span>反馈</span>
                                        </button>
                                    </div>
                                </div>

                                <div id="ms--inline-notifications" data-bi-name="inline-notification"></div>

                                <nav id="center-doc-outline"
                                    class="doc-outline is-hidden-desktop display-none-print margin-bottom-sm"
                                    data-bi-name="intopic toc" role="navigation" aria-label="本文内容">
                                    <h2 id="ms--in-this-article" class="title is-6 margin-block-xs">本文内容</h2>
                                </nav>

                                <!-- <content> -->
                                <p>自创建以来，C++ 即已成为世界上最常用的编程语言之一。 正确编写的 C++ 程序快速、高效。
                                    相对于其他语言，该语言更加灵活：它可以在最高的抽象级别上运行，还可以在硅级低级别上运行。 C++ 提供高度优化的标准库。
                                    它支持访问低级别硬件功能，从而最大限度地提高速度并最大程度地降低内存需求。 C++
                                    几乎可以创建任何类型的程序：游戏、设备驱动程序、HPC、云、桌面、嵌入式和移动应用等。 甚至用于其他编程语言的库和编译器也使用 C++ 编写。</p>
                                <p>C++ 的原始要求之一是与 C 语言向后兼容。 因此，C++ 始终允许 C 样式编程，其中包含原始指针、数组、以 null 结尾的字符串和其他功能。
                                    它们可以实现良好的性能，但也可能会引发 bug 并增加复杂性。 C++ 的演变注重可显著降低 C 样式惯例使用需求的功能。 如果需要，你仍可以使用旧的 C 编程设施。
                                    但是，在新式 C++ 代码中，对上述设施的需求会越来越少。 现代 C++ 代码更加简单、安全、美观，而且速度仍像以往一样快速。</p>
                                <p>下面几个部分概述了现代 C++ 的主要功能。 此处列出的功能在 C++11 及更高版本中可用，除非另有说明。 在 Microsoft C++ 编译器中，可以设置 <a
                                        href="../build/reference/std-specify-language-standard-version?view=msvc-170"
                                        data-linktype="relative-path"><code>/std</code></a> 编译器选项，指定要用于项目的标准版本。</p>
                                <h2 id="resources-and-smart-pointers">资源和智能指针</h2>
                                <p>C 样式编程的一个主要 bug 类型是内存泄漏<em></em>。 泄漏通常是由未能为使用 <strong><code>new</code></strong>
                                    分配的内存调用 <strong><code>delete</code></strong> 导致的。 现代 C++ 强调“资源获取即初始化<em></em>”(RAII)
                                    原则。 其理念很简单。 资源（堆内存、文件句柄、套接字等）应由对象<em></em>“拥有”。
                                    该对象在其构造函数中创建或接收新分配的资源，并在其析构函数中将此资源删除。 RAII 原则可确保当所属对象超出范围时，所有资源都能正确返回到操作系统。</p>
                                <p>为了支持对 RAII 原则的简单采用，C++ 标准库提供了三种智能指针类型：<a
                                        href="../standard-library/unique-ptr-class?view=msvc-170"
                                        data-linktype="relative-path"><code>std::unique_ptr</code></a>、<a
                                        href="../standard-library/shared-ptr-class?view=msvc-170"
                                        data-linktype="relative-path"><code>std::shared_ptr</code></a> 和 <a
                                        href="../standard-library/weak-ptr-class?view=msvc-170"
                                        data-linktype="relative-path"><code>std::weak_ptr</code></a>。
                                    智能指针可处理对其拥有的内存的分配和删除。 下面的示例演示了一个类，其中包含一个数组成员，该成员是在调用 <code>make_unique()</code>
                                    时在堆上分配的。 对 <strong><code>new</code></strong> 和 <strong><code>delete</code></strong>
                                    的调用将由 <code>unique_ptr</code> 类封装。 当 <code>widget</code> 对象超出范围时，将调用 unique_ptr
                                    析构函数，此函数将释放为数组分配的内存。</p>
                                <pre><code class="lang-cpp">#include &lt;memory&gt;
class widget
{
private:
    std::unique_ptr&lt;int[]&gt; data;
public:
    widget(const int size) { data = std::make_unique&lt;int[]&gt;(size); }
    void do_something() {}
};

void functionUsingWidget() {
    widget w(1000000);  // lifetime automatically tied to enclosing scope
                        // constructs w, including the w.data gadget member
    // ...
    w.do_something();
    // ...
} // automatic destruction and deallocation for w and w.data
</code></pre>
                                <p>请尽可能地使用智能指针管理堆内存。 如果必须显式使用 <strong><code>new</code></strong> 和
                                    <strong><code>delete</code></strong> 运算符，请遵循 RAII 原则。 有关详细信息，请参阅<a
                                        href="object-lifetime-and-resource-management-modern-cpp?view=msvc-170"
                                        data-linktype="relative-path">对象生存期和资源管理 (RAII)</a>。</p>
                                <h2 id="stdstring-and-stdstring_view"><code>std::string</code> 和
                                    <code>std::string_view</code></h2>
                                <p>C 样式字符串是 bug 的另一个主要来源。 通过使用 <a
                                        href="../standard-library/basic-string-class?view=msvc-170"
                                        data-linktype="relative-path"><code>std::string</code> 和
                                        <code>std::wstring</code></a>，几乎可以消除与 C 样式字符串关联的所有错误。
                                    还可以利用成员函数的优势进行搜索、追加和在前面追加等操作。 两者都对速度进行了高度优化。 将字符串传递到仅需要只读访问权限的函数时，在 C++17 中，可以使用 <a
                                        href="../standard-library/basic-string-view-class?view=msvc-170"
                                        data-linktype="relative-path"><code>std::string_view</code></a>，以便提高性能。</p>
                                <h2 id="stdvector-and-other-standard-library-containers"><code>std::vector</code>
                                    和其他标准库容器</h2>
                                <p>标准库容器都遵循 RAII 原则。 它们为安全遍历元素提供迭代器。 此外，它们对性能进行了高度优化，并且已充分测试正确性。
                                    通过使用这些容器，可以消除自定义数据结构中可能引入的 bug 或低效问题。 使用 <a
                                        href="../standard-library/vector-class?view=msvc-170"
                                        data-linktype="relative-path"><code>vector</code></a> 替代原始数组，来作为 C++ 中的序列容器。</p>
                                <pre><code class="lang-cpp">vector&lt;string&gt; apples;
apples.push_back(&quot;Granny Smith&quot;);
</code></pre>
                                <p>使用 <a href="../standard-library/map-class?view=msvc-170"
                                        data-linktype="relative-path"><code>map</code></a>（而不是
                                    <code>unordered_map</code>），作为默认关联容器。 对于退化和多案例，使用 <a
                                        href="../standard-library/set-class?view=msvc-170"
                                        data-linktype="relative-path"><code>set</code></a>、<a
                                        href="../standard-library/multimap-class?view=msvc-170"
                                        data-linktype="relative-path"><code>multimap</code></a> 和 <a
                                        href="../standard-library/multiset-class?view=msvc-170"
                                        data-linktype="relative-path"><code>multiset</code></a>。</p>
                                <pre><code class="lang-cpp">map&lt;string, string&gt; apple_color;
// ...
apple_color[&quot;Granny Smith&quot;] = &quot;Green&quot;;
</code></pre>
                                <p>需要进行性能优化时，请考虑以下用法：</p>
                                <ul>
                                    <li>
                                        <p>例如，当嵌入非常重要时，将 <a href="../standard-library/array-class-stl?view=msvc-170"
                                                data-linktype="relative-path"><code>array</code></a> 类型作为类成员。</p>
                                    </li>
                                    <li>
                                        <p>使用无序的关联容器，例如 <a href="../standard-library/unordered-map-class?view=msvc-170"
                                                data-linktype="relative-path"><code>unordered_map</code></a>。
                                            它们的每个元素的开销较低，并且具有固定时间查找功能，但正确高效地使用它们的难度更高。</p>
                                    </li>
                                    <li>
                                        <p>使用排序的 <code>vector</code>。 有关详细信息，请参阅<a
                                                href="../standard-library/algorithms?view=msvc-170"
                                                data-linktype="relative-path">算法</a>。</p>
                                    </li>
                                </ul>
                                <p>请勿使用 C 样式数组。 对于需要直接访问数据的旧 API，请改用 <code>f(vec.data(), vec.size());</code> 等访问器方法。
                                    有关容器的详细信息，请参阅 <a href="../standard-library/stl-containers?view=msvc-170"
                                        data-linktype="relative-path">C++ 标准库容器</a>。</p>
                                <h2 id="standard-library-algorithms">标准库算法</h2>
                                <p>在假设需要为程序编写自定义算法之前，请先查看 C++ 标准库<a href="../standard-library/algorithm?view=msvc-170"
                                        data-linktype="relative-path">算法</a>。 标准库包含许多常见操作（如搜索、排序、筛选和随机化）的算法分类，这些分类在不断增长。
                                    数学库的内容很广泛。 在 C++17 及更高版本中，提供了许多算法的并行版本。</p>
                                <p>以下是一些重要示例：</p>
                                <ul>
                                    <li>
                                        <p><code>for_each</code>，默认遍历算法（以及基于范围的 <code>for</code> 循环）。</p>
                                    </li>
                                    <li>
                                        <p><code>transform</code>，用于对容器元素进行非就地修改</p>
                                    </li>
                                    <li>
                                        <p><code>find_if</code>，默认搜索算法。</p>
                                    </li>
                                    <li>
                                        <p><code>sort</code>、<code>lower_bound</code> 和其他默认的排序和搜索算法。</p>
                                    </li>
                                </ul>
                                <p>若要编写比较运算符，请使用严格的 <strong><code>&lt;</code></strong>，并尽可能使用命名 lambda<em></em>。</p>
                                <pre><code class="lang-cpp">auto comp = [](const widget&amp; w1, const widget&amp; w2)
     { return w1.weight() &lt; w2.weight(); }

sort( v.begin(), v.end(), comp );

auto i = lower_bound( v.begin(), v.end(), widget{0}, comp );
</code></pre>
                                <h2 id="auto-instead-of-explicit-type-names">用 <code>auto</code> 替代显式类型名称</h2>
                                <p>C++11 引入了 <a href="auto-cpp?view=msvc-170"
                                        data-linktype="relative-path"><code>auto</code></a> 关键字，以便可将其用于变量、函数和模板声明中。
                                    <strong><code>auto</code></strong> 会指示编译器推导对象的类型，这样你就无需显式键入类型。
                                    当推导出的类型是嵌套模板时，<strong><code>auto</code></strong> 尤其有用：</p>
                                <pre><code class="lang-cpp">map&lt;int,list&lt;string&gt;&gt;::iterator i = m.begin(); // C-style
auto i = m.begin(); // modern C++
</code></pre>
                                <h2 id="range-based-for-loops">基于范围的 <code>for</code> 循环</h2>
                                <p>对数组和容器的 C 样式迭代容易引发索引错误，而且键入过程单调乏味。 若要消除这些错误，并提高代码的可读性，可使用基于范围的
                                    <strong><code>for</code></strong> 循环，此循环包含标准库容器和原始数组。 有关详细信息，请参阅<a
                                        href="range-based-for-statement-cpp?view=msvc-170"
                                        data-linktype="relative-path">基于范围的 <code>for</code> 语句</a>。</p>
                                <pre><code class="lang-cpp">#include &lt;iostream&gt;
#include &lt;vector&gt;

int main()
{
    std::vector&lt;int&gt; v {1,2,3};

    // C-style
    for(int i = 0; i &lt; v.size(); ++i)
    {
        std::cout &lt;&lt; v[i];
    }

    // Modern C++:
    for(auto&amp; num : v)
    {
        std::cout &lt;&lt; num;
    }
}
</code></pre>
                                <h2 id="constexpr-expressions-instead-of-macros">用 <code>constexpr</code> 表达式替代宏</h2>
                                <p>C 和 C++ 中的宏是指编译之前由预处理器处理的标记。 在编译文件之前，宏标记的每个实例都将替换为其定义的值或表达式。 C 样式编程通常使用宏来定义编译时常量值。
                                    但宏容易出错且难以调试。 在现代 C++ 中，应优先使用 <a href="constexpr-cpp?view=msvc-170"
                                        data-linktype="relative-path"><code>constexpr</code></a> 变量定义编译时常量：</p>
                                <pre><code class="lang-cpp">#define SIZE 10 // C-style
constexpr int size = 10; // modern C++
</code></pre>
                                <h2 id="uniform-initialization">统一初始化</h2>
                                <p>在现代 C++ 中，可以使用任何类型的括号初始化。 在初始化数组、矢量或其他容器时，这种初始化形式会非常方便。 在下面的示例中，使用三个 <code>S</code>
                                    实例初始化 <code>v2</code>。 <code>v3</code> 将使用三个 <code>S</code> 实例进行初始化，这些实例使用括号初始化自身。
                                    编译器基于 <code>v3</code> 声明的类型推断每个元素的类型。</p>
                                <pre><code class="lang-cpp">#include &lt;vector&gt;

struct S
{
    std::string name;
    float num;
    S(std::string s, float f) : name(s), num(f) {}
};

int main()
{
    // C-style initialization
    std::vector&lt;S&gt; v;
    S s1(&quot;Norah&quot;, 2.7);
    S s2(&quot;Frank&quot;, 3.5);
    S s3(&quot;Jeri&quot;, 85.9);

    v.push_back(s1);
    v.push_back(s2);
    v.push_back(s3);

    // Modern C++:
    std::vector&lt;S&gt; v2 {s1, s2, s3};

    // or...
    std::vector&lt;S&gt; v3{ {&quot;Norah&quot;, 2.7}, {&quot;Frank&quot;, 3.5}, {&quot;Jeri&quot;, 85.9} };

}
</code></pre>
                                <p>若要了解详细信息，请参阅<a
                                        href="initializing-classes-and-structs-without-constructors-cpp?view=msvc-170"
                                        data-linktype="relative-path">括号初始化</a>。</p>
                                <h2 id="move-semantics">移动语义</h2>
                                <p>现代 C++ 提供了移动语义<em></em>，此功能可以避免进行不必要的内存复制。 在此语言的早期版本中，在某些情况下无法避免复制。
                                    移动<em></em>操作会将资源的所有权从一个对象转移到下一个对象，而不必再进行复制。 一些类拥有堆内存、文件句柄等资源。
                                    实现资源所属的类时，可以定义此类的移动构造函数<em></em>和移动赋值运算符<em></em>。 在解析重载期间，如果不需要进行复制，编译器会选择这些特殊成员。
                                    如果定义了移动构造函数，则标准库容器类型会在对象中调用此函数。 有关详细信息，请参阅<a
                                        href="move-constructors-and-move-assignment-operators-cpp?view=msvc-170"
                                        data-linktype="relative-path">移动构造函数和移动赋值运算符 (C++)</a>。</p>
                                <h2 id="lambda-expressions">Lambda 表达式</h2>
                                <p>在 C 样式编程中，可以通过使用函数指针<em></em>将函数传递到另一个函数。 函数指针不便于维护和理解。
                                    它们引用的函数可能是在源代码的其他位置中定义的，而不是从调用它的位置定义的。 此外，它们不是类型安全的。 现代 C++ 提供了函数对象<em></em>和重写 <a
                                        href="function-call-operator-parens?view=msvc-170"
                                        data-linktype="relative-path"><code>operator()</code></a> 运算符的类，可以像调用函数一样调用它们。
                                    创建函数对象的最简便方法是使用内联 <a href="lambda-expressions-in-cpp?view=msvc-170"
                                        data-linktype="relative-path">lambda 表达式</a>。 下面的示例演示如何使用 lambda 表达式传递函数对象，然后由
                                    <code>find_if</code> 函数在矢量的每个元素中调用此函数对象：</p>
                                <pre><code class="lang-cpp">    std::vector&lt;int&gt; v {1,2,3,4,5};
    int x = 2;
    int y = 4;
    auto result = find_if(begin(v), end(v), [=](int i) { return i &gt; x &amp;&amp; i &lt; y; });
</code></pre>
                                <p>可以将 lambda 表达式 <code>[=](int i) { return i &gt; x &amp;&amp; i &lt; y; }</code>
                                    理解为“采用类型 <strong><code>int</code></strong> 的单个参数并返回一个布尔值来表示此参数是否大于 <code>x</code>
                                    并且小于 <code>y</code> 的函数”。请注意，可在 lambda 中使用来自周围上下文的 <code>x</code> 和 <code>y</code>
                                    变量。 <code>[=]</code> 会指定通过<em></em>值捕获这些变量；换言之，对于这些值，lambda 表达式具有自己的值副本。</p>
                                <h2 id="exceptions">异常</h2>
                                <p>与错误代码相比，新式 C++ 更注重异常，将其作为报告和处理错误条件的最佳方法。 有关详细信息，请参阅<a
                                        href="errors-and-exception-handling-modern-cpp?view=msvc-170"
                                        data-linktype="relative-path">现代 C++ 处理异常和错误的最佳做法</a>。</p>
                                <h2 id="stdatomic"><code>std::atomic</code></h2>
                                <p>对线程间通信机制使用 C++ 标准库 <a href="../standard-library/atomic-structure?view=msvc-170"
                                        data-linktype="relative-path"><code>std::atomic</code></a> 结构和相关类型。</p>
                                <h2 id="stdvariant-c17"><code>std::variant</code> (C++17)</h2>
                                <p>C 样式编程通常通过并集使不同类型的成员可以占用同一个内存位置，从而节省内存。 但是，并集不是类型安全的，并且容易导致编程错误。 C++17 引入了更加安全可靠的 <a
                                        href="../standard-library/variant-class?view=msvc-170"
                                        data-linktype="relative-path"><code>std::variant</code></a> 类，来作为并集的替代项。 可以使用 <a
                                        href="../standard-library/variant-functions?view=msvc-170#visit"
                                        data-linktype="relative-path"><code>std::visit</code></a> 函数以类型安全的方式访问
                                    <code>variant</code> 类型的成员。</p>
                                <h2 id="see-also">另请参阅</h2>
                                <p><a href="cpp-language-reference?view=msvc-170" data-linktype="relative-path">C++
                                        语言参考</a><br>
                                    <a href="lambda-expressions-in-cpp?view=msvc-170"
                                        data-linktype="relative-path">Lambda 表达式</a><br>
                                    <a href="../standard-library/cpp-standard-library-reference?view=msvc-170"
                                        data-linktype="relative-path">C++ 标准库</a><br>
                                    <a href="../overview/visual-cpp-language-conformance?view=msvc-170"
                                        data-linktype="relative-path">Microsoft C/C++ 语言一致性</a>
                                </p>

                            </div>

                            <div id="assertive-live-region" role="alert" aria-live="assertive" class="visually-hidden"
                                aria-relevant="additions" aria-atomic="true"></div>
                            <div id="polite-live-region" role="status" aria-live="polite" class="visually-hidden"
                                aria-relevant="additions" aria-atomic="true"></div>
                            <!-- </content> -->

                        </main>





                        <!-- recommendations section -->
                        <!-- end recommendations section -->

                        <!-- feedback section -->
                        <!-- end feedback section -->

                        <!-- feedback report section -->
                        <!-- end feedback report section -->

                        <div id="ms--additional-resources-mobile" role="complementary" aria-label="其他资源"
                            class="display-none-desktop display-none-print">
                            <hr class="hr" hidden />
                            <h2 id="ms--additional-resources-mobile-heading" class="title is-3" hidden>其他资源</h2>
                            <section id="right-rail-recommendations-mobile" data-bi-name="recommendations" hidden>
                            </section>
                            <section id="right-rail-training-mobile" data-bi-name="learning-resources-card" hidden>
                            </section>
                            <section id="right-rail-events-mobile" data-bi-name="events-card" hidden></section>
                            <section id="right-rail-qna-mobile" data-bi-name="qna-link-card" hidden></section>
                        </div>

                        <div class="border-top is-visible-interactive has-default-focus margin-top-sm ">



                            <footer id="footer-interactive" data-bi-name="footer" class="footer-layout">
                                <div class="display-flex gap-xs flex-wrap-wrap is-full-height padding-right-lg-desktop">
                                    <a data-mscc-ic="false"
                                        class="locale-selector-link button button-sm button-clear flex-shrink-0"
                                        href="#" data-bi-name="select-locale">
                                        <span class="icon" aria-hidden="true">
                                            <span class="docon docon-world"></span>
                                        </span>
                                        <span class="local-selector-link-text"></span></a>
                                    <div class="flex-shrink-0">
                                        <div class="dropdown has-caret-up">
                                            <button
                                                class="dropdown-trigger button button-clear button-sm has-inner-focus theme-dropdown-trigger"
                                                aria-controls="theme-menu-interactive" aria-expanded="false" title="主题"
                                                data-bi-name="theme">
                                                <span class="icon">
                                                    <span class="docon docon-sun" aria-hidden="true"></span>
                                                </span>
                                                <span>主题</span>
                                                <span class="icon expanded-indicator" aria-hidden="true">
                                                    <span class="docon docon-chevron-down-light"></span>
                                                </span>
                                            </button>
                                            <div class="dropdown-menu" id="theme-menu-interactive" role="menu">
                                                <ul class="theme-selector padding-xxs" role="none">
                                                    <li class="theme display-block" role="menuitem">
                                                        <button
                                                            class="button button-clear button-sm theme-control button-block justify-content-flex-start"
                                                            data-theme-to="light">
                                                            <span class="theme-light margin-right-xxs">
                                                                <span
                                                                    class="theme-selector-icon css-variable-support border display-inline-block has-body-background"
                                                                    aria-hidden="true">
                                                                    <svg class="svg" xmlns="http://www.w3.org/2000/svg"
                                                                        viewBox="0 0 22 14">
                                                                        <rect width="22" height="14"
                                                                            class="has-fill-body-background" />
                                                                        <rect x="5" y="5" width="12" height="4"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="5" y="2" width="2" height="1"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="8" y="2" width="2" height="1"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="11" y="2" width="3" height="1"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="1" y="1" width="2" height="2"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="5" y="10" width="7" height="2" rx="0.3"
                                                                            class="has-fill-primary" />
                                                                        <rect x="19" y="1" width="2" height="2" rx="1"
                                                                            class="has-fill-secondary" />
                                                                    </svg>
                                                                </span>
                                                            </span>
                                                            <span>
                                                                亮 </span>
                                                        </button>
                                                    </li>
                                                    <li class="theme display-block" role="menuitem">
                                                        <button
                                                            class="button button-clear button-sm theme-control button-block justify-content-flex-start"
                                                            data-theme-to="dark">
                                                            <span class="theme-dark margin-right-xxs">
                                                                <span
                                                                    class="border theme-selector-icon css-variable-support display-inline-block has-body-background"
                                                                    aria-hidden="true">
                                                                    <svg class="svg" xmlns="http://www.w3.org/2000/svg"
                                                                        viewBox="0 0 22 14">
                                                                        <rect width="22" height="14"
                                                                            class="has-fill-body-background" />
                                                                        <rect x="5" y="5" width="12" height="4"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="5" y="2" width="2" height="1"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="8" y="2" width="2" height="1"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="11" y="2" width="3" height="1"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="1" y="1" width="2" height="2"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="5" y="10" width="7" height="2" rx="0.3"
                                                                            class="has-fill-primary" />
                                                                        <rect x="19" y="1" width="2" height="2" rx="1"
                                                                            class="has-fill-secondary" />
                                                                    </svg>
                                                                </span>
                                                            </span>
                                                            <span>
                                                                暗 </span>
                                                        </button>
                                                    </li>
                                                    <li class="theme display-block" role="menuitem">
                                                        <button
                                                            class="button button-clear button-sm theme-control button-block justify-content-flex-start"
                                                            data-theme-to="high-contrast">
                                                            <span class="theme-high-contrast margin-right-xxs">
                                                                <span
                                                                    class="border theme-selector-icon css-variable-support display-inline-block has-body-background"
                                                                    aria-hidden="true">
                                                                    <svg class="svg" xmlns="http://www.w3.org/2000/svg"
                                                                        viewBox="0 0 22 14">
                                                                        <rect width="22" height="14"
                                                                            class="has-fill-body-background" />
                                                                        <rect x="5" y="5" width="12" height="4"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="5" y="2" width="2" height="1"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="8" y="2" width="2" height="1"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="11" y="2" width="3" height="1"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="1" y="1" width="2" height="2"
                                                                            class="has-fill-secondary" />
                                                                        <rect x="5" y="10" width="7" height="2" rx="0.3"
                                                                            class="has-fill-primary" />
                                                                        <rect x="19" y="1" width="2" height="2" rx="1"
                                                                            class="has-fill-secondary" />
                                                                    </svg>
                                                                </span>
                                                            </span>
                                                            <span>
                                                                高对比度 </span>
                                                        </button>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <ul class="links" data-bi-name="footerlinks">
                                    <li class="manage-cookies-holder" hidden></li>
                                    <li><a class="external-link-indicator" data-mscc-ic="false"
                                            href="/zh-cn/previous-versions/" data-bi-name="archivelink">早期版本</a></li>
                                    <li><a class="external-link-indicator" data-mscc-ic="false"
                                            href="https://techcommunity.microsoft.com/t5/microsoft-learn-blog/bg-p/MicrosoftLearnBlog"
                                            data-bi-name="bloglink">博客</a></li>
                                    <li><a class="external-link-indicator" data-mscc-ic="false"
                                            href="/zh-cn/contribute/" data-bi-name="contributorGuide">参与</a></li>
                                    <li><a class="external-link-indicator" data-mscc-ic="false"
                                            href="https://go.microsoft.com/fwlink/?LinkId=521839"
                                            data-bi-name="privacy">隐私</a></li>
                                    <li><a class="external-link-indicator" data-mscc-ic="false"
                                            href="/zh-cn/legal/termsofuse" data-bi-name="termsofuse">使用条款</a></li>
                                    <li><a class="external-link-indicator" data-mscc-ic="false"
                                            href="https://www.microsoft.com/legal/intellectualproperty/Trademarks/"
                                            data-bi-name="trademarks">商标</a></li>
                                    <li>&copy; Microsoft 2023</li>
                                </ul>
                            </footer>
                        </div>

                    </div>

                    <div id="ms--additional-resources"
                        class="right-container column is-4-desktop display-none display-block-desktop"
                        data-bi-name="pageactions" role="complementary" aria-label="其他资源">
                        <div id="affixed-right-container" class="margin-top-sm-tablet" data-bi-name="right-column">
                            <h2 id="ms--additional-resources-heading" class="title is-6 margin-top-md" hidden>其他资源</h2>
                            <section id="right-rail-events" data-bi-name="events-card" hidden></section>
                            <section id="right-rail-training" data-bi-name="learning-resources-card" hidden></section>
                            <section id="right-rail-recommendations" data-bi-name="recommendations" hidden></section>
                            <nav id="side-doc-outline" class="doc-outline" data-bi-name="intopic toc" role="navigation"
                                aria-label="本文内容">
                                <h3>本文内容</h3>
                            </nav>
                            <section id="right-rail-qna" class="margin-top-xxs" data-bi-name="qna-link-card" hidden>
                            </section>
                        </div>
                    </div>

                </div>
                <!--end of div.columns -->

            </section>
            <!--end of .primary-holder -->

            <!-- interactive container -->
            <aside id="interactive-container"
                class="interactive-container is-visible-interactive column has-body-background-dark ">
            </aside>
            <!-- end of interactive container -->
        </div>

    </div>
    <!--end of .mainContainer -->

    <section class="border-top has-default-focus is-hidden-interactive margin-top-sm ">



        <footer id="footer" data-bi-name="footer" class="footer-layout uhf-container has-padding" role="contentinfo">
            <div class="display-flex gap-xs flex-wrap-wrap is-full-height padding-right-lg-desktop">
                <a data-mscc-ic="false" class="locale-selector-link button button-sm button-clear flex-shrink-0"
                    href="#" data-bi-name="select-locale">
                    <span class="icon" aria-hidden="true">
                        <span class="docon docon-world"></span>
                    </span>
                    <span class="local-selector-link-text"></span></a>
                <div class="flex-shrink-0">
                    <div class="dropdown has-caret-up">
                        <button
                            class="dropdown-trigger button button-clear button-sm has-inner-focus theme-dropdown-trigger"
                            aria-controls="theme-menu" aria-expanded="false" title="主题" data-bi-name="theme">
                            <span class="icon">
                                <span class="docon docon-sun" aria-hidden="true"></span>
                            </span>
                            <span>主题</span>
                            <span class="icon expanded-indicator" aria-hidden="true">
                                <span class="docon docon-chevron-down-light"></span>
                            </span>
                        </button>
                        <div class="dropdown-menu" id="theme-menu" role="menu">
                            <ul class="theme-selector padding-xxs" role="none">
                                <li class="theme display-block" role="menuitem">
                                    <button
                                        class="button button-clear button-sm theme-control button-block justify-content-flex-start"
                                        data-theme-to="light">
                                        <span class="theme-light margin-right-xxs">
                                            <span
                                                class="theme-selector-icon css-variable-support border display-inline-block has-body-background"
                                                aria-hidden="true">
                                                <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 14">
                                                    <rect width="22" height="14" class="has-fill-body-background" />
                                                    <rect x="5" y="5" width="12" height="4"
                                                        class="has-fill-secondary" />
                                                    <rect x="5" y="2" width="2" height="1" class="has-fill-secondary" />
                                                    <rect x="8" y="2" width="2" height="1" class="has-fill-secondary" />
                                                    <rect x="11" y="2" width="3" height="1"
                                                        class="has-fill-secondary" />
                                                    <rect x="1" y="1" width="2" height="2" class="has-fill-secondary" />
                                                    <rect x="5" y="10" width="7" height="2" rx="0.3"
                                                        class="has-fill-primary" />
                                                    <rect x="19" y="1" width="2" height="2" rx="1"
                                                        class="has-fill-secondary" />
                                                </svg>
                                            </span>
                                        </span>
                                        <span>
                                            亮 </span>
                                    </button>
                                </li>
                                <li class="theme display-block" role="menuitem">
                                    <button
                                        class="button button-clear button-sm theme-control button-block justify-content-flex-start"
                                        data-theme-to="dark">
                                        <span class="theme-dark margin-right-xxs">
                                            <span
                                                class="border theme-selector-icon css-variable-support display-inline-block has-body-background"
                                                aria-hidden="true">
                                                <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 14">
                                                    <rect width="22" height="14" class="has-fill-body-background" />
                                                    <rect x="5" y="5" width="12" height="4"
                                                        class="has-fill-secondary" />
                                                    <rect x="5" y="2" width="2" height="1" class="has-fill-secondary" />
                                                    <rect x="8" y="2" width="2" height="1" class="has-fill-secondary" />
                                                    <rect x="11" y="2" width="3" height="1"
                                                        class="has-fill-secondary" />
                                                    <rect x="1" y="1" width="2" height="2" class="has-fill-secondary" />
                                                    <rect x="5" y="10" width="7" height="2" rx="0.3"
                                                        class="has-fill-primary" />
                                                    <rect x="19" y="1" width="2" height="2" rx="1"
                                                        class="has-fill-secondary" />
                                                </svg>
                                            </span>
                                        </span>
                                        <span>
                                            暗 </span>
                                    </button>
                                </li>
                                <li class="theme display-block" role="menuitem">
                                    <button
                                        class="button button-clear button-sm theme-control button-block justify-content-flex-start"
                                        data-theme-to="high-contrast">
                                        <span class="theme-high-contrast margin-right-xxs">
                                            <span
                                                class="border theme-selector-icon css-variable-support display-inline-block has-body-background"
                                                aria-hidden="true">
                                                <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 14">
                                                    <rect width="22" height="14" class="has-fill-body-background" />
                                                    <rect x="5" y="5" width="12" height="4"
                                                        class="has-fill-secondary" />
                                                    <rect x="5" y="2" width="2" height="1" class="has-fill-secondary" />
                                                    <rect x="8" y="2" width="2" height="1" class="has-fill-secondary" />
                                                    <rect x="11" y="2" width="3" height="1"
                                                        class="has-fill-secondary" />
                                                    <rect x="1" y="1" width="2" height="2" class="has-fill-secondary" />
                                                    <rect x="5" y="10" width="7" height="2" rx="0.3"
                                                        class="has-fill-primary" />
                                                    <rect x="19" y="1" width="2" height="2" rx="1"
                                                        class="has-fill-secondary" />
                                                </svg>
                                            </span>
                                        </span>
                                        <span>
                                            高对比度 </span>
                                    </button>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            <ul class="links" data-bi-name="footerlinks">
                <li class="manage-cookies-holder" hidden></li>
                <li><a class="external-link-indicator" data-mscc-ic="false" href="/zh-cn/previous-versions/"
                        data-bi-name="archivelink">早期版本</a></li>
                <li><a class="external-link-indicator" data-mscc-ic="false"
                        href="https://techcommunity.microsoft.com/t5/microsoft-learn-blog/bg-p/MicrosoftLearnBlog"
                        data-bi-name="bloglink">博客</a></li>
                <li><a class="external-link-indicator" data-mscc-ic="false" href="/zh-cn/contribute/"
                        data-bi-name="contributorGuide">参与</a></li>
                <li><a class="external-link-indicator" data-mscc-ic="false"
                        href="https://go.microsoft.com/fwlink/?LinkId=521839" data-bi-name="privacy">隐私</a></li>
                <li><a class="external-link-indicator" data-mscc-ic="false" href="/zh-cn/legal/termsofuse"
                        data-bi-name="termsofuse">使用条款</a></li>
                <li><a class="external-link-indicator" data-mscc-ic="false"
                        href="https://www.microsoft.com/legal/intellectualproperty/Trademarks/"
                        data-bi-name="trademarks">商标</a></li>
                <li>&copy; Microsoft 2023</li>
            </ul>
        </footer>
    </section>

    <div id="action-panel" role="region" aria-label="操作面板" class="action-panel has-default-focus" tabindex="-1"></div>
</body>

</html>